﻿using System;
using System.Collections.ObjectModel;
using System.Linq;

namespace GifAnimator.AnimatedImage
{
    public class AnimatedImage
    {
        public ObservableCollection<ImageFrame> Frames { get; set; }
        public UInt16 NbLoop { get; set; }
        public UInt32 TotalDuration
        {
            get
            {
                return GetTotalDuration();
            }
        }
        public Boolean InfiniteLoop
        {
            get
            {
                return (NbLoop == 0 ? true : false);
            }
        }

        public AnimatedImage()
        {
            Frames = new ObservableCollection<ImageFrame>();
            NbLoop = 0;
        }
        private UInt32 GetTotalDuration()
        {
            return (UInt32)Frames.Sum(l => l.Duration);
        }
    }
}